<?php
// +----------------------------------------------------------------------
// | Description: 1
// +----------------------------------------------------------------------
// | Author: orchief
// +----------------------------------------------------------------------
// | Date: 2018-01-24 16:13:32
// +----------------------------------------------------------------------

namespace app\client\controller;

use app\common\controller\Common;
use EasyWeChat\Factory;

class Wechat extends Common
{
    public function menus()
    {
        $config = [
            'app_id' => config('wechat.app_id'),
            'secret' => config('wechat.secret'),
            // 指定 API 调用返回结果的类型：array(default)/collection/object/raw/自定义类名
            'response_type' => 'array',

            'log' => [
                'level' => 'debug',
                'file' => __DIR__ . '/wechat.log',
            ],
        ];

        $app = Factory::officialAccount($config);
        $list = $app->material->list('image', 0, 20);
        // $buttons = [
        //     [
        //         "type" => "view",
        //         "name" => "进入商城",
        //         "url" => "http://wx.yingdun.com.cn/wx/home"
		// 	],
        //     [
        //         "name" => "会员入口",
        //         "sub_button" => [
        //             [
        //                 "type" => "view",
        //                 "name" => "登录",
        //                 "url" => "http://wx.yingdun.com.cn/wx/login"
        //             ],
        //             [
        //                 "type" => "view",
        //                 "name" => "注册",
        //                 "url" => "http://wx.yingdun.com.cn/wx/register"
        //             ]
        //         ],
        //     ],
        //     [
        //         "name" => "联系客服",
        //         "sub_button" => [
        //             [
        //                 "type" => "click",
        //                 "name" => "联系电话",
        //                 "key" => "server-phone"
        //             ],
        //             [
        //                 "type" => "click",
        //                 "name" => "微信客服",
        //                 "key" => "server-people"
        //             ]
        //         ],
        //     ]
        // ];
        // $res = $app->menu->create($buttons);
        var_dump($list);
    }
}